package beautysalonsystem.exception;


import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.util.SaResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(NotLoginException.class)
    public SaResult handleNotLogin(NotLoginException e, HttpServletResponse response) throws IOException {
        response.setStatus(401);//TODO 需要前端配合跳转至登录页面
        return SaResult.error("未登录或登录已失效，请重新登录");
    }
}